package logic

import (
	"common/dao/model"
	"common/mysql"
	"fmt"
	"gateway/websocket/types"
	"github.com/jinzhu/copier"
)

func GetFileList(req types.SysFileRequest, data *types.ServiceMessage) error {
	var (
		resp = types.SysFileRespList{}
	)
	fmt.Println(req)
	qu := mysql.QueryList{
		Page:    int(req.Page),
		Size:    int(req.PageSize),
		Key:     "name",
		FindKey: req.Keyword,
		DB:      DB,
	}

	list, total, err := mysql.GETList[model.SysFile](&qu)
	if err != nil {
		return err
	}
	err = copier.Copy(&resp.List, list)
	resp.Total = int32(total)
	data.Data = resp
	return nil
}
